package com.apartment.own.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.apartment.common.annotation.Log;
import com.apartment.common.core.controller.BaseController;
import com.apartment.common.core.domain.AjaxResult;
import com.apartment.common.enums.BusinessType;
import com.apartment.own.domain.OwnAccountPayment;
import com.apartment.own.service.IOwnAccountPaymentService;
import com.apartment.common.utils.poi.ExcelUtil;
import com.apartment.common.core.page.TableDataInfo;

/**
 * 支付详情Controller
 * 
 * @author @Dog_E
 * @date 2020-08-28
 */
@RestController
@RequestMapping("/own/payment")
public class OwnAccountPaymentController extends BaseController
{
    @Autowired
    private IOwnAccountPaymentService ownAccountPaymentService;

    /**
     * 查询支付详情列表
     */
    @PreAuthorize("@ss.hasPermi('own:payment:list')")
    @GetMapping("/list")
    public TableDataInfo list(OwnAccountPayment ownAccountPayment)
    {
        startPage();
        List<OwnAccountPayment> list = ownAccountPaymentService.selectOwnAccountPaymentList(ownAccountPayment);
        return getDataTable(list);
    }

    /**
     * 导出支付详情列表
     */
    @PreAuthorize("@ss.hasPermi('own:payment:export')")
    @Log(title = "支付详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OwnAccountPayment ownAccountPayment)
    {
        List<OwnAccountPayment> list = ownAccountPaymentService.selectOwnAccountPaymentList(ownAccountPayment);
        ExcelUtil<OwnAccountPayment> util = new ExcelUtil<OwnAccountPayment>(OwnAccountPayment.class);
        return util.exportExcel(list, "payment");
    }

    /**
     * 获取支付详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('own:payment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ownAccountPaymentService.selectOwnAccountPaymentById(id));
    }

    /**
     * 新增支付详情
     */
    @PreAuthorize("@ss.hasPermi('own:payment:add')")
    @Log(title = "支付详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OwnAccountPayment ownAccountPayment)
    {
        return toAjax(ownAccountPaymentService.insertOwnAccountPayment(ownAccountPayment));
    }

    /**
     * 修改支付详情
     */
    @PreAuthorize("@ss.hasPermi('own:payment:edit')")
    @Log(title = "支付详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OwnAccountPayment ownAccountPayment)
    {
        return toAjax(ownAccountPaymentService.updateOwnAccountPayment(ownAccountPayment));
    }

    /**
     * 删除支付详情
     */
    @PreAuthorize("@ss.hasPermi('own:payment:remove')")
    @Log(title = "支付详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ownAccountPaymentService.deleteOwnAccountPaymentByIds(ids));
    }
}
